﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmMantenimientoCliente.aspx.cs" Inherits="Aurora.Web.Mantenimiento.frmMantenimientoCliente" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div class="alert alert-success alert-dismissable" runat="server" id="divSuccess">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><span class="glyphicon glyphicon-ok"></span>&nbsp;<strong>Exito!&nbsp;</strong>El proceso se ha realizado con exito.
    </div>
    <div class="alert alert-danger alert-dismissable" runat="server" id="divError">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><span class="glyphicon glyphicon-remove"></span>&nbsp;<strong>Alerta!&nbsp;</strong>No se pudo completar el proceso
    </div>
    <div class="page-header">
        <h3><span class="glyphicon glyphicon-list-alt"></span>&nbsp;Mantenimiento de Clientes</h3>
    </div>
    <br />
    <div class="form-horizontal" role="form">
        <div class="form-group">
            <label for="inNombre" class="col-md-1 control-label">Nombre</label>
            <div class="col-md-3">
                <input type="text" class="form-control" id="inNombre" placeholder="Nombre de la empresa cliente" runat="server" />
            </div>
            <label for="inRUC" class="col-md-1 control-label">RUC</label>
            <div class="col-md-3">
                <input type="text" class="form-control" id="inRUC" placeholder="Ejemplo: 102918282" runat="server" />
            </div>
            <div class="col-md-2">
                <asp:Button CssClass="btn btn-default" runat="server" ID="btnBuscar" OnClick="btnBuscar_Click" Text="Buscar" />
            </div>
        </div>
    </div>
    <div>
        <button class="btn btn-primary" data-toggle="modal" data-target="#myModal">Agregar cliente</button><br />
        <br />
        <asp:GridView runat="server" ID="gridClientes" CssClass="table table-bordered table-responsive" EmptyDataText="No hay resultados para su busqueda." AutoGenerateColumns="false" OnRowCommand="gridClientes_RowCommand" OnRowCancelingEdit="gridClientes_RowCancelingEdit" OnRowEditing="gridClientes_RowEditing" OnRowUpdating="gridClientes_RowUpdating"
            AllowPaging="true" PageSize="20" OnPageIndexChanging="gridClientes_PageIndexChanging" OnRowDeleting="gridClientes_RowDeleting">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblID" Text='<%# Eval("CLI_ID") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle CssClass="hiddencol" />
                    <HeaderStyle CssClass="hiddencol" />
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <a href='<%# "frmMantenimientoSucursal.aspx?SUC_ID=" + Eval("CLI_ID") %>' title="Ver detalle"><span class="glyphicon glyphicon-eye-open"></span></a>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Nombre">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblNombre" Text='<%# Eval("CLI_NOMBRE") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox runat="server" ID="txtNombre" Text='<%# Eval("CLI_NOMBRE") %>' Width="100%" CssClass="form-control"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemStyle Width="20%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="RUC">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblRUC" Text='<%# Eval("CLI_RUC") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox runat="server" ID="txtRUC" Text='<%# Eval("CLI_RUC") %>' Width="100%" CssClass="form-control"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemStyle Width="15%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Direccion legal">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblDireccion" Text='<%# Eval("CLI_DIRECCION") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox runat="server" ID="txtDireccion" Text='<%# Eval("CLI_DIRECCION") %>' Width="100%" CssClass="form-control"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemStyle Width="45%" />
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="lnkUpdate" runat="server" CausesValidation="True" CommandName="Update" CommandArgument='<%# Container.DataItemIndex %>' CssClass="btn btn-sm btn-success"><span class="glyphicon glyphicon-floppy-disk"></span>&nbsp;Actualizar</asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="lnkCancel" runat="server" CausesValidation="False" CommandName="Cancel" CssClass="btn btn-sm btn-danger"><span class="glyphicon glyphicon-remove-circle"></span>&nbsp;Cancelar</asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="lnkEdit" runat="server" CausesValidation="False" CommandName="Edit" CssClass="btn btn-sm btn-info"><span class="glyphicon glyphicon-pencil"></span>&nbsp;Editar</asp:LinkButton>
                        &nbsp;<asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" CommandName="Delete" CommandArgument='<%# Container.DataItemIndex %>' CssClass="btn btn-sm btn-danger" OnClientClick="return confirm('Se eliminara el registro permanentemente. Desea continuar?')"><span class="glyphicon glyphicon-trash"></span>&nbsp;Eliminar</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="20%" />
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    <asp:HiddenField runat="server" ID="hfNombre" />
    <asp:HiddenField runat="server" ID="hfRuc" />

    <!-- Nuevo Cliente -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Nuevo Cliente</h4>
                </div>
                <div class="modal-body">
                    <div class="form-horizontal" role="form">
                        <div class="form-group">
                            <label for="inNombre" class="col-md-3 control-label">Nombre</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" id="txtNuevoNombre" placeholder="Nombre de la empresa cliente" runat="server" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inRUC" class="col-md-3 control-label">RUC</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" id="txtNuevoRUC" placeholder="Ejemplo: 102918282" runat="server" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inDireccion" class="col-md-3 control-label">Direccion</label>
                            <div class="col-md-9">
                                <input type="text" class="form-control" id="txtNuevaDireccion" placeholder="Direccion legal de la empresa" runat="server" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                    <asp:Button CssClass="btn btn-primary" runat="server" id="btnAgregarNuevo" Text="Guardar" OnClick="btnAgregarNuevo_Click"></asp:Button>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
